﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace MoneyWentWhere.Utils
{
    public struct Tuple<T1, T2>
    {
        public readonly T1 Item1;
        public readonly T2 Item2;

        public Tuple(T1 item1, T2 item2)
        {
            if (item1 == null) { throw new ArgumentNullException("item1"); }
            if (item2 == null) { throw new ArgumentNullException("item2"); }

            Item1 = item1;
            Item2 = item2;
        }

        public override bool Equals(object obj)
        {
            if (!(obj is Tuple<T1, T2>)) { return false; }

            Tuple<T1, T2> that = (Tuple<T1, T2>)obj;
            return Item1.Equals(that.Item1) && Item2.Equals(that.Item2);
        }

        public override int GetHashCode()
        {
            int hash = 17;
            hash = hash * 31 + Item1.GetHashCode();
            hash = hash * 31 + Item2.GetHashCode();
            return hash;
        }

        public override string ToString()
        {
            return String.Format("<{0},{1}>", Item1, Item2);
        }
    }
}
